package com.gitee.dolt.utils;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ClassUtil;

/**
 * @author LYH
 */
public class BeanUtils {

    public static <T> T toBean(Object source, Class<T> clazz) {
        if (ClassUtil.isAssignable(clazz, source.getClass())) {
            return (T) source;
        }
        return BeanUtil.toBean(source, clazz);
    }

    public static <T> T toBeanIgnoreError(Object source, Class<T> clazz) {
        if (ClassUtil.isAssignable(clazz, source.getClass())) {
            return (T) source;
        }
        return BeanUtil.toBeanIgnoreError(source, clazz);
    }

}
